Add swiglu + MXFP8 fused CuTe DSL kernel - #2
Open
wolfcomos wants to merge 1 commit into
Open
Conversation
wolfcomos
force-pushed
the
agent/swiglu-mxfp8-unified
branch
from
August 9, 2026 08:10
9853226 to
26f6cf7
Compare
wolfcomos
force-pushed
the
agent/swiglu-mxfp8-unified
branch
4 times, most recently
from
August 12, 2026 22:36
22783a1 to
8ad8a79
Compare
wolfcomos
force-pushed
the
agent/swiglu-mxfp8-unified
branch
4 times, most recently
from
August 13, 2026 07:22
486ceaf to
94489e8
Compare
wolfcomos
marked this pull request as ready for review
August 13, 2026 07:25
wolfcomos
force-pushed
the
agent/swiglu-mxfp8-unified
branch
3 times, most recently
from
August 19, 2026 05:14
39db529 to
61eb093
Compare
… Blackwell One CuTe DSL kernel fuses the gated activation (forward and backward) with the RCEIL MXFP8 cast: gate/up are read once and the bf16 activation never round-trips through global memory. Rowwise (1x32), colwise (32x1), or both scale modes come out of a single pass, in the same blocked tcgen05 layouts as the standalone quantizers, and bit-compatible with their special-value semantics (pytorch#4725 contract: NaN/Inf amax invalidates the block with scale byte 255 and all-NaN data; byte-0 scales descale by 2^127). Ops: torchao::gated_act_mxfp8_{forward,backward} custom ops with fake impls (torch.compile fullgraph works), public wrappers, 80-case numerics suite (bitwise forward, one-code-bounded backward), and an A/B benchmark vs the unfused Triton-activation + standalone-quantizer path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
wolfcomos
force-pushed
the
agent/swiglu-mxfp8-unified
branch
from
August 24, 2026 05:43
61eb093 to
7e08b94
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds one CuTe DSL kernel that fuses the swiglu with the RCEIL MXFP8 cast:
gate/upare read once, the bf16 activation tensor is never materialized, and rowwise (1x32), colwise (32x1), or both scales come outof a single pass. This kernel is bit-compatible with the standalone mxfp8 cute dsl quantizers. The consuming
composite autograd op lives in torchtitan branch https://github.com/wolfcomos/torchtitan/pull/2/changes (will refactor for upstream torchtitan PR soon), this torchao PR is kernels-only.
Performance
GB200, torch 2.14 nightly, CUDA 13.4, public DSL 4.7.0. Baseline is an already-fused-activation arm: torch.compile-fused SwiGLU (one static Triton kernel per shape) + the standalone CuTe DSL quantizers
Eager:
This host had application clocks pinned to 2062 Mhz.
End-to-end in torchtitan (DeepSeek-V3 16B, 4x GB200, EP=4, TP=1, batch 4, seq 4096, MXFP8 MoE recipe, 50 steps), three arms — the stock MXFP8 path, the fused-w13 MoE composite running the unfused activation + standalone quantizers, and the same composite backed by this PR's kernels:
Net +2.5% throughput (+3.0% vs the structurally identical unfused composite the kernel-only effect), median step time -1.8%, loss parity (max spread 3.5e-3 at step 50), and the tightest step-time tail (max step 869 ms vs 1081 stock).
The same A/B under the BF16-wgrad recipe (
mxfp8_rceil_wgrad_with_hp: the kernel emits rowwise-only casts, and the composite recomputes the activation in BF16 at the autograd boundary for the two wgrad GEMMs — a boundary with less redundant traffic for fusion to remove):The fused kernel still wins here (+1.2% throughput, -0.7% median step, kernel-only), with the margin narrowed as expected for the cheaper boundary.
API
gated_inputpacks[gate | up]— the layout a fused w13 projection produces; backward returns concatenated[dGate | dUp], so there is notorch.caton the hot path. Disabled directions come back zero-sized (fixed arity). Registered as torch custom ops with fake impls;torch.compile(fullgraph=True)works. One kernel source: direction,layout mode, and the activation (a module-level
Constexprpolicy function,_silu_pair) are compile-time parameters; shapes are runtime, so one compilation per mode serves every shape.Numerics and tests
FakeTensorMode; pointer-alignment and geometry-override guards, each with a bitwise positive case); opt-in largest-legal-shape check against the standalone quantizer. Upstream's cutedsltest_mxfp8_dsl_special_value_semanticscases pass in the same environment.Reproducing
Follow-ups
SiLU is the only activation exposed today, plan to add more activations in future PR.
the TorchAO op itself has no register_sharding or automatic fallback. The external TorchTitan composite must choose the unfused path before invoking it, so there might be kernel sharding register work need to do for torchtitan integration.